package com.qfedu.yanglao20admin.refund.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.common.annotation.LogInfo;
import com.qfedu.yanglao20.entity.refund.CancelConfiguration;
import com.qfedu.yanglao20admin.refund.param.CancelConfigurationParam;
import com.qfedu.yanglao20admin.refund.service.CancelConfigurationService;
import com.qfedu.yanglao20admin.refund.vo.CancelConfigurationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yujie
 * @data 2023/5/5 17:33
 */
@Api(tags = "取消订单配置")
@RestController
@RequestMapping("/allocation")
public class CancelConfigurationController {

    @Resource
    private CancelConfigurationService cancelConfigurationService;

    @LogInfo
    @ApiOperation(value = "分页展示取消订单配置信息", notes = "分页展示取消订单配置信息")
    @GetMapping("/page")
    public CommonResult<CancelConfiguration> page(CancelConfigurationParam param) {
        Page<CancelConfigurationVO> cancelConfigurationVOPage = cancelConfigurationService.pageCancelConfiguration(param);
        return CommonResult.success(cancelConfigurationVOPage);
    }

    @LogInfo
    @ApiOperation(value = "根据id删除取消订单配置信息", notes = "根据id删除取消订单配置信息")
    @GetMapping("/delete")
    public CommonResult<CancelConfiguration> deleteCancelConfiguration(@RequestParam @ApiParam("取消订单配置id") Integer id) {
        cancelConfigurationService.deleteById(id);
        return CommonResult.success();
    }

    @LogInfo
    @ApiOperation(value = "添加取消订单配置信息", notes = "添加取消订单配置信息")
    @PostMapping("/add")
    public CommonResult<CancelConfiguration> addCancelConfiguration(CancelConfiguration cancelConfiguration) {
        cancelConfigurationService.addCancelConfiguration(cancelConfiguration);
        return CommonResult.success();
    }

    @LogInfo
    @ApiOperation(value = "根据id查询取消订单配置信息", notes = "根据id查询取消订单配置信息")
    @GetMapping("/query")
    public CommonResult<CancelConfiguration> queryCancelConfiguration(@RequestParam @ApiParam("取消订单配置id") Integer id) {
        CancelConfiguration cancelConfiguration = cancelConfigurationService.queryCancelConfiguration(id);
        return CommonResult.success(cancelConfiguration);
    }

    @LogInfo
    @ApiOperation(value = "修改取消订单配置信息", notes = "修改取消订单配置信息")
    @PostMapping("/update")
    public CommonResult<CancelConfiguration> updateCancelConfiguration(CancelConfiguration cancelConfiguration) {
        cancelConfigurationService.updateCancelConfiguration(cancelConfiguration);
        return CommonResult.success();
    }
}
